#ifndef DECISION_H
#define DECISION_H
#include "npc.h"
#include "player.h"
class decisionTreeNode{
	public:
	
	decisionTreeNode();
	~decisionTreeNode();
	
	void addTrueNode(decisionTreeNode* trueNode);
	void addFalseNode(decisionTreeNode* falseNode);
	
	decisionTreeNode* trueNode;
	decisionTreeNode* falseNode;
	
	virtual bool makeDecision(npc * npcGuy, player * hero){
	 return(0);}
};

//Child class to decisionTreeNode
class closeToPlayer96: public decisionTreeNode{
	public:
	//checks to see if the non playable charactor is 96 pixels away from
	//the player
	bool makeDecision(npc * npcGuy, player * hero){
		int numX=npcGuy->x-hero->x;
		int numY=npcGuy->y-hero->y;
		if(((numX*numX)+(numY*numY))<=9216)
		return true;
		else return false;
		}
};

//Child class to decisionTreeNode
class closeToPlayer32: public decisionTreeNode{
	public:
	//checs to see if the non playable character is 32 pixels away from
	//the player
	bool makeDecision(npc * npcGuy, player * hero){
		int numX=npcGuy->x-hero->x;
		int numY=npcGuy->y-hero->y;
		if(((numX*numX)+(numY*numY))<=1024)
		return true;
		else return false;
		}
};

class moveToGoalCheck: public decisionTreeNode{
	public:
	bool makeDecision(npc * npcGuy, player * hero){
		return npcGuy->moveToGoalCheck();
	}
};

//Child class to decisionTreeNode
class goalSetToPlayer: public decisionTreeNode{
	public:
		//checks to see if the x and y goals of the non playable character is 
		//equal to the player's x and y coordinate
		bool makeDecision(npc * npcGuy, player * hero){
			if(npcGuy->goal_x==hero->x&&npcGuy->goal_y==hero->y)
				return true;
			else return false;
		}
};

//Child class to decisionTreeNode
class goalSetToWaypoint: public decisionTreeNode{
	public:
		//checks to see if the non playable character's x and y goals 
		//are equal to one of it's waypoints
		bool makeDecision(npc* npcGuy, player * hero){
			int size=npcGuy->wayPointX.size();
		for(int i=0; i < size; i++){
			if(npcGuy->goal_x==npcGuy->wayPointX[i]&&npcGuy->goal_y==npcGuy->wayPointY[i]){
			return true;
		}
	}
	return false;
	}
};

//Child class to decisionTreeNode
class setGoalToPlayer: public decisionTreeNode{
	public:
	//sets the goal of the non playable character to the players x and y
	//coordinate
	bool makeDecision(npc * npcGuy, player * hero){
		npcGuy->setGoal(hero->x, hero->y);
		return true;
	}
};

//Child class to decisionTreeNode
class update: public decisionTreeNode{
	public:
	//Runs the updatNpc function move the non playable character closer
	//to it's goal values
	bool makeDecision(npc * npcGuy, player * hero){
		npcGuy->updateNpc();
		return true;
	}
};

//Child class to decisionTreeNode
class changeToNextPoint: public decisionTreeNode{
	public:
	//Runs the changeToNexPoint function on a non playable character.
	//This will change non playable character's waypoint to the next one
	// in the waypoint vector
	bool makeDecision(npc * npcGuy, player * hero){
		npcGuy->changeToNextPoint();
		return true;
	}
};

//Child class to decisionTreeNode
class attackP: public decisionTreeNode{
	public:
	//Runs the attackPlayer function for the non playable character. 
	//This will attack the player, possibly taking health.
	bool makeDecision(npc * npcGuy, player * hero){
		npcGuy->attackPlayer();
		return true;
	}
};

//Child class to decisionTreeNode
class setGoalToWaypoint: public decisionTreeNode{
	public:
	//Sets the goal of the non playable character to the first waypoint
	// in a non playable character's waypoint vector
	bool makeDecision(npc * npcGuy, player * hero){
		npcGuy->setGoal(npcGuy->wayPointX[0], npcGuy->wayPointY[0]);
		return true;
	}
};

//Constructor
decisionTreeNode::decisionTreeNode(){
	trueNode=NULL;
	falseNode=NULL;
}

//Destructor
decisionTreeNode::~decisionTreeNode(){
}

//Assigns a node's true node connection
void decisionTreeNode::addTrueNode(decisionTreeNode* trueNode){
	this->trueNode=trueNode;
}

//Assigns a node's false node connection
void decisionTreeNode::addFalseNode(decisionTreeNode* falseNode){
	this->falseNode=falseNode;
}
#endif 
